﻿var bookmark;
if(document.createRange) {
	var range=document.createRange();
} else {
	var range=document.body.createTextRange();
	bookmark=range.getBookmark();
}
var key;
for(var i=0;key=keys[i];i++) {
	if(range.findText) {
		range.collapse(true);
		range.moveToBookmark(bookmark);
		while(range.findText(key[0])) {
			range.pasteHTML(range.text.fontcolor(key[2]).link(key[1]));
		}
	} else {
		var s,n;
		s=window.getSelection();
		s.collapse(document.body,0);
		if(navigator.userAgent.indexOf("Chrome")== -1&&navigator.userAgent.indexOf("Safari")== -1) {
			while(window.find(key[0])) {
				var n=document.createElement("a");
				n.style.color=key[2];
				n.href=key[1];
				s.getRangeAt(0).surroundContents(n);
			}
		}
		
		/*var re=new RegExp("("+key[0]+")","ig");
		document.getElementById('global_main').innerHTML=document.getElementById('global_main').innerHTML.replace(re,function() {
		var u=arguments[0];						
		return u.fontcolor(key[2]).link(key[1]);
		});*/
		
	}
}